using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class Test_LogInfo
    {
		#region Local Variable
		public enum Field
		{
			No,
			Line,
			Test_ID,
			User_ID,
			Question_ID,
			Score,
			Creation_Time,
			Display_Time,
			Comment,
			Change_Time,
			Type
		}
		private Int32 _No;
		private Int32 _Line;
		private Int64 _Test_ID;
		private Int64 _User_ID;
		private Int64 _Question_ID;
		private Decimal _Score;
		private Int32 _Creation_Time;
		private Int32 _Display_Time;
		private String _Comment;
		private Int32 _Change_Time;
		private String _Type;
		
		public Int32 No{	get{ return _No;} set{_No = value;} }
		public Int32 Line{	get{ return _Line;} set{_Line = value;} }
		public Int64 Test_ID{	get{ return _Test_ID;} set{_Test_ID = value;} }
		public Int64 User_ID{	get{ return _User_ID;} set{_User_ID = value;} }
		public Int64 Question_ID{	get{ return _Question_ID;} set{_Question_ID = value;} }
		public Decimal Score{	get{ return _Score;} set{_Score = value;} }
		public Int32 Creation_Time{	get{ return _Creation_Time;} set{_Creation_Time = value;} }
		public Int32 Display_Time{	get{ return _Display_Time;} set{_Display_Time = value;} }
		public String Comment{	get{ return _Comment;} set{_Comment = value;} }
		public Int32 Change_Time{	get{ return _Change_Time;} set{_Change_Time = value;} }
		public String Type{	get{ return _Type;} set{_Type = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public Test_LogInfo()
		{
			_No = 0;
			_Line = 0;
			_Test_ID = 0;
			_User_ID = 0;
			_Question_ID = 0;
			_Score = 0;
			_Creation_Time = 0;
			_Display_Time = 0;
			_Comment = "";
			_Change_Time = 0;
			_Type = "";
		}
		public Test_LogInfo(
		Int32 No,
		Int32 Line,
		Int64 Test_ID,
		Int64 User_ID,
		Int64 Question_ID,
		Decimal Score,
		Int32 Creation_Time,
		Int32 Display_Time,
		String Comment,
		Int32 Change_Time,
		String Type
		)
		{
			_No = No;
			_Line = Line;
			_Test_ID = Test_ID;
			_User_ID = User_ID;
			_Question_ID = Question_ID;
			_Score = Score;
			_Creation_Time = Creation_Time;
			_Display_Time = Display_Time;
			_Comment = Comment;
			_Change_Time = Change_Time;
			_Type = Type;
		}
		public Test_LogInfo(DataRow dr)
		{
			if (dr != null)
			{
				_No = dr[Field.No.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.No.ToString()]);
				_Line = dr[Field.Line.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Line.ToString()]);
				_Test_ID = dr[Field.Test_ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.Test_ID.ToString()]);
				_User_ID = dr[Field.User_ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.User_ID.ToString()]);
				_Question_ID = dr[Field.Question_ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.Question_ID.ToString()]);
				_Score = dr[Field.Score.ToString()] == DBNull.Value?0:Convert.ToDecimal(dr[Field.Score.ToString()]);
				_Creation_Time = dr[Field.Creation_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Creation_Time.ToString()]);
				_Display_Time = dr[Field.Display_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Display_Time.ToString()]);
				_Comment = dr[Field.Comment.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Comment.ToString()]);
				_Change_Time = dr[Field.Change_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Change_Time.ToString()]);
				_Type = dr[Field.Type.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Type.ToString()]);
			}
		}
		public Test_LogInfo(Test_LogInfo objEntr)
		{			
			_No = objEntr.No;			
			_Line = objEntr.Line;			
			_Test_ID = objEntr.Test_ID;			
			_User_ID = objEntr.User_ID;			
			_Question_ID = objEntr.Question_ID;			
			_Score = objEntr.Score;			
			_Creation_Time = objEntr.Creation_Time;			
			_Display_Time = objEntr.Display_Time;			
			_Comment = objEntr.Comment;			
			_Change_Time = objEntr.Change_Time;			
			_Type = objEntr.Type;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Test_Log");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.No.ToString(), typeof(Int32)),
				new DataColumn(Field.Line.ToString(), typeof(Int32)),
				new DataColumn(Field.Test_ID.ToString(), typeof(Int64)),
				new DataColumn(Field.User_ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Question_ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Score.ToString(), typeof(Decimal)),
				new DataColumn(Field.Creation_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.Display_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.Comment.ToString(), typeof(String)),
				new DataColumn(Field.Change_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.Type.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.No.ToString()] = _No;
			row[Field.Line.ToString()] = _Line;
			row[Field.Test_ID.ToString()] = _Test_ID;
			row[Field.User_ID.ToString()] = _User_ID;
			row[Field.Question_ID.ToString()] = _Question_ID;
			row[Field.Score.ToString()] = _Score;
			row[Field.Creation_Time.ToString()] = _Creation_Time;
			row[Field.Display_Time.ToString()] = _Display_Time;
			row[Field.Comment.ToString()] = _Comment;
			row[Field.Change_Time.ToString()] = _Change_Time;
			row[Field.Type.ToString()] = _Type;
			return row;
		}
        #endregion InitTable
    }
}
